package uk.ac.sanger.utils;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

import org.biojava.dasobert.dasregistry.DasSource;


/**
 * class to read private sources from the sanger configuration file to filter from the sources response
 * @author jw12
 *
 */
public class ReadPrivateSources {

	
	public static void main(String args[]){
		ReadPrivateSources publicSources=new ReadPrivateSources();
		publicSources.readPrivateIds();
	}
	
	public Set <String> readPrivateIds(){
		HashSet <String>privateIds=new HashSet<String>();
		InputStream inStream = this.getClass().getResourceAsStream("/das_config.ini");
		BufferedReader das_configFile = new BufferedReader ( new InputStreamReader ( inStream ) );
		//File file = new File(path);// read in sources from proserver
		
		BufferedReader reader=new BufferedReader(das_configFile);
		try {
			String line=null;
			while((line=reader.readLine())!=null){
			
				if(!line.contains("public")){
					if(line.contains("=")){
					String id=line.substring(0,line.lastIndexOf("=")).trim();
					privateIds.add(id);
					}
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return privateIds;
	}
}
